package nekomv.server;

import general.Log;

class ClientData
{

    public var socket : neko.net.Socket;
    public var id : Int;
    public var peer : String;
    public var port : String;
    
    public var nick : String;
    
    public static var idcount : Int = 1;

    public var events : List<String>;
    public var parsequeue : List<String>;
    
    public function new(socket : neko.net.Socket)
    {
        events = new List();
        parsequeue = new List();

        this.socket = socket;
        this.id = idcount;
        idcount+=1;

        this.nick = "Guest"+this.id;

        var peer = socket.peer();
        this.peer = Std.string(peer.host);
        this.port = Std.string(peer.port);

        Log.init(this.peer+":"+this.port
                +" - uid #"+Std.string(this.id));
    }

    public function addEvent(e : String)
    {
        events.add(e+String.fromCharCode(0));
    }
    
    public function error(msg : String)
    {
        addEvent("E"+msg);
    }
    
    public function echo(msg : String)
    {
        addEvent("e"+msg);
    }

}